package com.hisense.ovcloud.warehouse.config;

import com.hisense.ovcloud.commons.tools.LocalLFUCacheUtil;
import com.hisense.ovcloud.warehouse.dto.common.DeviceInfoInCache;
import com.hisense.ovcloud.warehouse.dto.common.DomainInfoDto;
import com.hisense.ovcloud.warehouse.entity.matrix.DomainInfo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class LocalCacheConfig {
    private final WarehouseProperties warehouseProperties;

    public LocalCacheConfig(WarehouseProperties warehouseProperties) {
        this.warehouseProperties = warehouseProperties;
    }

    @Bean
    @Qualifier("deviceCache")
    public LocalLFUCacheUtil<DeviceInfoInCache> deviceCache(){
        return new LocalLFUCacheUtil<>(warehouseProperties.getLocalcacheCapacity());
    }

    @Bean
    @Qualifier("fetureCodeCache")
    public LocalLFUCacheUtil<DomainInfoDto> fetureCodeCache(){
        return new LocalLFUCacheUtil<>(1000);
    }

    @Bean
    @Qualifier("domainInfoCache")
    public LocalLFUCacheUtil<Map<String, DomainInfo>> domainInfoCache(){
        return new LocalLFUCacheUtil<>(1000);
    }
}
